package WaiBao;

import java.util.Arrays;

public class WangXingYue {
    public static void main(String[] args) {
        String[] name = {"李热(班长)", "王凯(副班长)", "小李(学习委员)", "拟好(文艺委员)", "王静婷", "李子豪", "郭紫", "杨幂", "杨金婷", "李潇潇", "王原子", "戴天理",
                "倪大红", "王志文", "王劲松", "洪金宝", "孙悟空", "猪八戒", "沙和尚", "唐僧", "白龙马", "高必", "王博", "王勃", "小猪", "小黑", "大白", "贝塔",
                "米老鼠", "王新月(学生)"};//考生本人:王新月(学生)
        int[] age = {21, 22, 23, 19, 22, 20, 19, 18, 21, 19, 18, 18,19, 20, 20, 19, 18, 18, 18, 18, 19, 19, 20, 20, 20, 18, 21, 19, 21, 20};//考生本人年龄:20

        double[] yihan1 = {88, 62, 76, 94, 97, 70, 78, 89, 81, 91, 91, 87, 85, 69, 65, 68, 69, 79, 96, 84, 92, 91, 95, 65, 75, 74, 91, 77, 60, 96};
        double[] yihan2 = {67, 65, 65, 76, 88, 67, 68, 64, 74, 80, 92, 77, 66, 85, 85, 65, 76, 99, 76, 98, 72, 71, 95, 86, 75, 88, 88, 69, 71, 96};
        double[] yihan3 = {69, 67, 84, 85, 75, 64, 78, 69, 80, 80, 93, 87, 85, 65, 69, 68, 69, 96, 96, 93, 92, 81, 65, 95, 76, 84, 77, 75, 85, 95};


        double zhide1 ;//代表每个学生的总分
        double zhide2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            zhide1=yihan1[i] +yihan2[i] +yihan3[i];
//            zhide2 = (zhide1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + zhide1);
//            System.out.println(name[i] + "的平均分为:" + zhide2);
//        }

        double ming1 = 0, ming2 = 0;
        double[] jielun = new double[30];
//        for (int i = 0; i < 30; i++) {
//            ming1= yihan1[i] + yihan2[i] + yihan3[i];
//            ming2 = (ming1* 1.0) / 3;
//            jielun[i] = ming2;
//        }
//
//        for (int i = 0; i < jielun.length - 1; i++) {
//            for (int j = 0; j <  jielun.length - i - 1; j++) {
//                if (jielun[j] <jielun[j + 1]) {
//                    double tep =jielun[j];
//                    jielun[j] = jielun[j + 1];
//                    jielun[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println( jielun[i]);
//        }


        double queyue1 = 0,  queyue2 = 0, queyue3 = 0;//计算每门课的平均分
        double renran1 = 0, renran2 = 0, renran3 = 0;//计算每门课标准差
        double gaunzhu1 = 0,gaunzhu2 = 0, gaunzhu3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i < yihan1.length; i++) {
            he += yihan1[i];
        }
        queyue1 = (he * 1.0) / 30;
        System.out.println("农业设施及环境调控的班级平均分为:" + queyue1);
        double Sum = 0;
        for (int i = 0; i < yihan2.length; i++) {
            Sum +=yihan2[i];
        }
        queyue2 = (Sum * 1.0) / 30;
        System.out.println("农业设施设计与建造的班级平均分为:" +  queyue2);
        double sum = 0;
        for (int i = 0; i <yihan3.length; i++) {
            sum +=yihan3[i];
        }
        queyue3 = (sum * 1.0) / 30;
        System.out.println("园艺植物设施栽培学的班级平均分为:" +  queyue3);



        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i <yihan1.length; i++) {
            c1 += (yihan1[i] -  queyue1) * (yihan1[i] - queyue1);
        }
        renran1 = Math.sqrt(c1*1.0/30);
        System.out.println("农业设施及环境调控的班级标准差为:" +renran1);
        for (int i = 0; i <yihan2.length; i++) {
            c2 += (yihan2[i] -  queyue2) * (yihan2[i] - queyue2);
        }
        renran2 = Math.sqrt(c2*1.0/30);
        System.out.println("农业设施设计与建造的班级标准差为:" +renran2);

        for (int i = 0; i <yihan3.length; i++) {
            c3 += (yihan3[i] -  queyue3) * (yihan3[i] -  queyue3);
        }
        renran3 = Math.sqrt(c3*1.0/30);
        System.out.println("园艺植物设施栽培学的标准差为:" + renran3);
////////
        Arrays.sort(yihan1);
        Arrays.sort(yihan2);
        Arrays.sort(yihan3);
        gaunzhu1 = (yihan1[15] + yihan2[14]) * 1.0 / 2;
        gaunzhu2 = (yihan2[15] + yihan2[14]) * 1.0 / 2;
        gaunzhu3 = (yihan3[15] + yihan3[14]) * 1.0 / 2;
        System.out.println("农业设施及环境调控的中位数为:" + gaunzhu1);
        System.out.println("农业设施设计与制造的中位数为:" + gaunzhu2);
        System.out.println("园艺植物设施栽培学的中位数为:" + gaunzhu3);


    }
}
